package com.greensam.pixelengine.websocket.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 消息推送事件类型
 *
 * @author Ma Chengrui
 * @since 2025/10/10 16:39
 */
@Getter
@AllArgsConstructor
public enum WebSocketEventType {

    CONNECTED("CONNECTED", "连接成功"),
    DISCONNECTED("DISCONNECTED", "断开连接"),

    PICTURE_EXIT("PICTURE_EXIT", "图片编辑"),
    ERROR("ERROR", "发送错误"),

    ;

    private final String code;
    private final String desc;

    /**
     * 根据 code 获取枚举
     */
    public static WebSocketEventType fromCode(String code) {
        for (WebSocketEventType value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

}
